import 'package:flutter/material.dart';
import 'package:my_app/common/common.dart';
import 'package:my_app/passport/passport.dart';

import 'package:my_app/service/http/http.dart';

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // return Column(
    //   children: [
    //     Image.network(
    //       "https://img1.baidu.com/it/u=3886212450,854269223&fm=26&fmt=auto&gp=0.jpg",
    //       height: 900,
    //     ),
    //   ],
    // );
    return Scaffold(
      body: Container(
        child: Flex(
          direction: Axis.vertical,
          children: [
            InkWell(
              child: Expanded(
                child: Container(
                  height: 1800,
                  color: Colors.red,
                  child: Image.network(
                    "https://img1.baidu.com/it/u=3886212450,854269223&fm=26&fmt=auto&gp=0.jpg",
                    fit: BoxFit.cover,
                  ),
                ),
                flex: 2,
              ),
              onTap: () {
                print('InkWell');
                HttpRequest.get();
              },
            ),
            ButtonGroup(),
          ],
        ),
      ),
    );
  }
}

class ButtonGroup extends StatelessWidget {
  const ButtonGroup({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final ButtonStyle buttonStyle = Common.buttonStyle;
    TextStyle buttonTextStyle = Common.buttonTextStyle;

    return Container(
      padding: EdgeInsets.all(10),
      child: Flex(
        direction: Axis.horizontal,
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          Expanded(
            child: Container(
              padding: EdgeInsets.all(10),
              child: TextButton(
                style: buttonStyle,
                child: Text(
                  "中文",
                  style: buttonTextStyle,
                ),
                onPressed: () {
                  Navigator.of(context).push(
                    MaterialPageRoute(
                      builder: (context) {
                        return Passport();
                      },
                    ),
                  );

                  print("中文");
                },
              ),
            ),
            flex: 1,
          ),
          Expanded(
            child: Container(
              padding: EdgeInsets.all(10),
              child: TextButton(
                style: buttonStyle,
                child: Text(
                  "日语",
                  style: buttonTextStyle,
                ),
                onPressed: () {
                  print("日语");
                },
              ),
            ),
            flex: 1,
          ),
          Expanded(
            child: Container(
              padding: EdgeInsets.all(10),
              child: TextButton(
                style: buttonStyle,
                child: Text(
                  "英语",
                  style: buttonTextStyle,
                ),
                onPressed: () {
                  print("英语");
                },
              ),
            ),
            flex: 1,
          ),
        ],
      ),
    );
  }
}
